{extend name="dialog"}


{block name="content"}
<div class="layui-tab-content" style="height: 85%!important;">
    <table id="robotTable" data-url="{:sysuri('robots')}" data-target-search="form.form-search"></table>
</div>
{/block}

{block name="script"}
<script>
    $(function(){
        $('#robotTable').layTable({
            even: true,
            height: 'auto',
            sort: {field: 'id', type: 'desc'},
            where: {type: 'robot'},
            cols: [[
                {checkbox: true, fixed: true},
                {
                    field: 'id',
                    title: 'Id',
                    width: 100,
                    align: 'center',
                    sort: true
                },
                {
                    field: 'headimg', title: '头像', width: 80, align: 'center', templet: function (d) {
                        if (!d.headimg) return '-';
                        return layui.laytpl('<div class="headimg headimg-ss shadow-inset margin-0" data-tips-image data-tips-hover data-lazy-src="{{d.headimg}}"></div>').render(d);
                    }
                },
                {
                    field: 'nickname',
                    title: '用户名称',
                    minWidth: 100,
                    align: 'center',
                    templet: '<div>{{d.nickname||"-"}}</div>'
                },
                {field: 'create_at', title: '创建时间', align: 'center', minWidth: 170, sort: true},
                {toolbar: '#toolbar', title: '操作', align: 'center', minWidth: 150, fixed: 'right'}
            ]]
        });

        setTimeout(() => layui.table.reload('robotTable'), 200);
    });
</script>

<!-- 数据状态切换模板 -->
<script type="text/html" id="StatusSwitchTpl">
    <!--{if auth("state")}-->
    <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{-d.status>0?'checked':''}}>
    <!--{else}-->
    {{-d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}
    <!--{/if}-->
</script>

<!-- 列表排序权重模板 -->
<script type="text/html" id="SortInputTpl">
    <input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
</script>

<script type="text/html" id="toolbar">
    <!--{if auth("edit")}-->
    <a class="layui-btn layui-btn-sm" data-event-click data-title="选择" lay-filter="choice">选 择</a>
    <!--{/if}-->
</script>
{/block}